// Do session prompt here and then save the info in an Application Storage variable for use in
// the shutdown procsesing in sessionmanager.js
let watcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher);
let app = this.getApp();
// if didn't already shut down
if (app && !app.storage.get(SM_ALREADY_SHUTDOWN, false)) {
let bundle = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService).createBundle("chrome://sessionmanager/locale/sessionmanager.properties");
// Manually construct the prompt window because the promptService doesn't allow 4 button prompts
let params = Cc["@mozilla.org/embedcomp/dialogparam;1"].createInstance(Ci.nsIDialogParamBlock);
params.SetInt(0, 1); // Set default to cancel
params.SetString(0, bundle.GetStringFromName("preserve_session")); // dialog text
params.SetString(1, bundle.GetStringFromName("prompt_not_again")); // checkbox text
params.SetString(12, bundle.GetStringFromName("sessionManager")); // title
// buttons are tricky because they don't display in order
// if there are 4 buttons they display as 11, 8, 10, 9
// if there are 3 buttons they display as 8, 10, 9
// A button always returns it's string number - 8, eg: 10 returns 2.
// So we need to tweak things when displaying 3 or 4 buttons.
if (resume_current) {
params.SetInt(2, 3); // Display 3 buttons
params.SetString(8, bundle.GetStringFromName("save_quit")); // first button text (returns 0)
params.SetString(10, bundle.GetStringFromName("quit")); // second button text (returns 2)
params.SetString(9, bundle.GetStringFromName("cancel")); // third button text (returns 1)
}
else {
params.SetInt(2, 4); // Display 4 buttons
params.SetString(11, bundle.GetStringFromName("save_quit")); // first button text (returns 3)
params.SetString(8, bundle.GetStringFromName("quit")); // second button text (returns 0)
params.SetString(10, bundle.GetStringFromName("save_and_restore")); // third button text (returns 2)
params.SetString(9, bundle.GetStringFromName("cancel")); // fourth button text (returns 1)